package com.example.thread;

import java.util.concurrent.CountDownLatch;

import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import com.example.handler.DecodeHandler;
import com.example.loopertest.MainActivity;

public class DecodeThread extends Thread {
	private static final String TAG = DecodeThread.class.getSimpleName();
	
	private CountDownLatch count = new CountDownLatch(1);
	private Handler dh;
	private Activity activity;
	public static final String BARCODE_BITMAP = "barcode_bitmap";
	
	public DecodeThread(Activity activity) {
		this.activity = activity;
	}
	@Override
	public void run() {
		Log.i(TAG,"DecodeThread:"+Thread.currentThread().getId());
		Looper.prepare();
		
		dh = new DecodeHandler(this.activity);
		count.countDown();
		
		Looper.loop();
		
	}
	
	public Handler getHandler() {
		try {
			count.await();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return dh;
		
		
	}

	
}
